const uploadUrl = 'https://honor-hall.oss-cn-chengdu.aliyuncs.com'
const downloadUrl = 'https://honor-hall.oss-cn-chengdu.aliyuncs.com/rongyaowxapp/'
// const downloadSingleUrl = 'https://czcollege.oss-cn-beijing.aliyuncs.com/'
export const uploadToOss = (filePath) => {
	return new Promise(function (resolve, reject) {
	  let policy = 'eyJleHBpcmF0aW9uIjoiMjEwMC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ=='
	  let ossId = 'LTAI5tBpgxzdmEJsBEqwd74n'
	  let signature = 'cF4+Pelir48n3BVabZJvAiI+E1o='
	  let key = filePath.slice(15)
	  uni.uploadFile({
	    url: uploadUrl,
	    filePath: filePath,
	    name: 'file',
	    formData: {
	      'name': key,
	      'key': 'rongyaowxapp/' + key,
	      'policy': policy,
	      'OSSAccessKeyId': ossId,
	      'signature': signature,
	      'success_action_status': '200'
	    },
	    success(res) {
	      console.log("-----------upload success!-------", res)
	      var url = downloadUrl + key
	      resolve({url,key})
	    },
	    fail(err) {
	      console.log('-----------upload fail!--------',err)
		  uni.showModal({
		    title: '上传失败',
		    content: '请切换网络后重试',
		  })
	    }
	  })
	});
}

